#include<iostream>
using namespace std;
void hafuCoding(HAF hafuTree[],char* haffcoding[], int n)
{
	char* temp = new char[n];
	temp[n - 1] = '\0';
	for (int i = 0; i < n; i++)
	{
		int start = n-1;
		int pos = i;
		int parent = hafuTree[i].parent;
		while (parent != -1)
		{
			if (hafuTree[i].lchild == pos) {
				temp[--start] = '0';
			}
			else {
				temp[--start] = '1';
			}
			pos = parent;
			parent = hafuTree[parent].parent;
		}
		haffcoding[i] = new char[n - start];
		strcpy(haffcoding[i], &temp[start]);
	}
}